package com.ctshk.app.train.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.train.dto.es.MainDataStationCacheDTO;
import com.ctshk.rpc.train.service.ITrainProductAppAndPcService;
import com.ctshk.rpc.train.service.ITrainProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 火车产品表 前端控制器
 * </p>
 *
 * @author 彭柳霖
 * @since 2021-03-11
 */
@Api(value="火车站点信息", tags="火车站点信息")
@RestController
@RequestMapping("/train-station")
public class TrainStationController extends BaseController {

    @DubboReference
    ITrainProductAppAndPcService trainProductAppServiceImpl;

    @DubboReference
    private ITrainProductService trainProductService;

    @ApiOperation(value="火车站点-查询", notes="火车站点-查询")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "火车站点-查询", operDesc = "火车站点-查询")
    @GetMapping("/query")
    public Result<List<MainDataStationCacheDTO>> query(@RequestParam("stationName") String stationName) {
        return trainProductAppServiceImpl.query(stationName);
    }

    @ApiOperation(value="test", notes="test")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "火车站点-查询", operDesc = "火车站点-查询")
    @GetMapping("/test")
    public Result findTrainSalePriceInfoHandle(
            @RequestParam(value = "strategyType") int strategyType,
            @RequestParam(value = "productId") Long productId,
            @RequestParam(value = "departureDate") String departureDate,
            @RequestParam(value = "relId")Long relId) {
        return Result.success(trainProductService.findTrainSalePriceInfoHandle(strategyType,
                productId, LocalDate.parse(departureDate), relId));
    }

}
